package com.corticon.client.model;

import java.io.Serializable;


public class ResponseEntryApiOutput implements Serializable, Comparable  {
	private String label;
	private Integer responseEntryId;
	private String value;
	private String sequence;

	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	public Integer getResponseEntryId() {
		return responseEntryId;
	}

	public void setResponseEntryId(Integer responseEntryId) {
		this.responseEntryId = responseEntryId;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getSequence() {
		return sequence;
	}

	public void setSequence(String sequence) {
		this.sequence = sequence;
	}
	@Override
	public int compareTo(Object o) {
		ResponseEntryApiOutput another = (ResponseEntryApiOutput) o;
		String[] newSequence = sequence.split("\\.");
		String[] anotherSequence = another.getSequence().split("\\.");
		// 1.10 --1.2
		if (newSequence.length >= anotherSequence.length) {
			for (int i = 0; i < newSequence.length; i++) {
				String s1 = newSequence[i];
				String s2 = "0";
				if (i < anotherSequence.length) {
					s2 = anotherSequence[i];
				}
				if (s1.equals(s2)) {
					continue;
				} else {
					return Integer.valueOf(s1)-Integer.valueOf(s2);
				}
			}
		} else {
			for (int i = 0; i < anotherSequence.length; i++) {
				String s1 = "0";
				String s2 = anotherSequence[i];
				if (i < newSequence.length) {
					s1 = newSequence[i];
				}
				if (s1.equals(s2)) {
					continue;
				} else {
					return Integer.valueOf(s1)-Integer.valueOf(s2);
				}
			}
		}
		return sequence.compareTo(another.getSequence());
    }
}
